<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->


<!DOCTYPE html
  PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="zh-cn" xml:lang="zh-cn">
<head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="DC.Type" content="topic">
<meta name="DC.Title" content="恢复MySQL/MariaDB/GreatSQL数据库">
<meta name="product" content="">
<meta name="DC.Relation" scheme="URI" content="mysql-0046.html">
<meta name="prodname" content="">
<meta name="version" content="">
<meta name="brand" content="30-OceanProtect 备份一体机 1.5.0-1.6.0 帮助中心">
<meta name="DC.Publisher" content="20240320">
<meta name="documenttype" content="usermanual">
<meta name="prodname" content="csbs">
<meta name="DC.Format" content="XHTML">
<meta name="DC.Identifier" content="mysql-0049">
<meta name="DC.Language" content="zh-cn">
<link rel="stylesheet" type="text/css" href="public_sys-resources/commonltr.css">
<title>恢复MySQL/MariaDB/GreatSQL数据库</title>
</head>
<body style="clear:both; padding-left:10px; padding-top:5px; padding-right:5px; padding-bottom:5px"><a name="mysql-0049"></a><a name="mysql-0049"></a>

<h1 class="topictitle1">恢复MySQL/MariaDB/GreatSQL数据库</h1>
<div><p>当需要对已备份的数据库进行恢复时，可以参考本节使用副本恢复数据库至原位置或新位置。</p>
<div class="section"><h4 class="sectiontitle">前提条件</h4><ul><li>执行恢复任务前，请确认目标位置数据库已关闭。</li><li>恢复前请确保恢复目标位置的数据目录剩余空间大于恢复副本缩减前大小，否则恢复将失败。</li><li>执行恢复任务前，需确保mysqlbinlog、mysqldump、mysqld、mysqladmin和mysql软连接配置正确。请参见<a href="mysql-0014.html">步骤2：手动配置软连接</a>。</li></ul>
</div>
<div class="section"><h4 class="sectiontitle">操作步骤</h4><ol><li><span>选择<span class="uicontrol" id="mysql-0049__zh-cn_topic_0000001839142377_uicontrol734315167278">“<span id="mysql-0049__zh-cn_topic_0000001839142377_text133437163275">数据利用</span> &gt; <span id="mysql-0049__zh-cn_topic_0000001839142377_text143431916102710">副本数据</span> &gt; <span id="mysql-0049__zh-cn_topic_0000001839142377_text159620466494">数据库</span> &gt; <span id="mysql-0049__zh-cn_topic_0000001839142377_text69125533114">MySQL/MariaDB</span>/GreatSQL”</span>。</span></li><li><span>您可以以MySQL/MariaDB/GreatSQL资源维度或以副本维度查找副本，本节以资源维度为例进行说明。</span><p><p>在<span class="uicontrol">“<span>资源</span>”</span>页签，根据资源名称查找到需要恢复的资源，并单击资源名称。</p>
</p></li><li><span>依次选择年、月、天找到副本。</span><p><p>当时间上显示<span><img src="zh-cn_image_0000001839222661.png"></span>，即表示该月、该天存在副本。</p>
</p></li><li><span>在副本所在行，单击<span class="uicontrol">“<span>更多</span> &gt; <span>恢复</span>”</span>。</span><p><p>相关参数说明如<a href="#mysql-0049__zh-cn_topic_0000001263614142_table93951625101715">表1</a>所示。</p>

<div class="tablenoborder"><a name="mysql-0049__zh-cn_topic_0000001263614142_table93951625101715"></a><a name="zh-cn_topic_0000001263614142_table93951625101715"></a><table cellpadding="4" cellspacing="0" summary="" id="mysql-0049__zh-cn_topic_0000001263614142_table93951625101715" frame="border" border="1" rules="all"><caption><b>表1 </b>恢复MySQL/MariaDB/GreatSQL数据库参数说明</caption><colgroup><col style="width:32.53%"><col style="width:67.47%"></colgroup><thead align="left"><tr><th align="left" class="cellrowborder" valign="top" width="32.53%" id="mcps1.3.3.2.4.2.2.2.3.1.1"><p>参数</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="67.47%" id="mcps1.3.3.2.4.2.2.2.3.1.2"><p>说明</p>
</th>
</tr>
</thead>
<tbody><tr><td class="cellrowborder" valign="top" width="32.53%" headers="mcps1.3.3.2.4.2.2.2.3.1.1 "><p><span>恢复至</span></p>
</td>
<td class="cellrowborder" valign="top" width="67.47%" headers="mcps1.3.3.2.4.2.2.2.3.1.2 "><p>选择恢复至<span class="uicontrol">“<span>原位置</span>”</span>或<span class="uicontrol">“<span>新位置</span>”</span>。</p>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="32.53%" headers="mcps1.3.3.2.4.2.2.2.3.1.1 "><p><span>位置</span></p>
</td>
<td class="cellrowborder" valign="top" width="67.47%" headers="mcps1.3.3.2.4.2.2.2.3.1.2 "><p>当选择恢复至<span class="uicontrol">“<span>原位置</span>”</span>时，默认显示恢复的位置。</p>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="32.53%" headers="mcps1.3.3.2.4.2.2.2.3.1.1 "><p><span>目标实例</span></p>
</td>
<td class="cellrowborder" valign="top" width="67.47%" headers="mcps1.3.3.2.4.2.2.2.3.1.2 "><p>当选择恢复至“<span>新位置</span>”时，请选择恢复到的目标实例。</p>
<div class="note"><span class="notetitle"> 说明： </span><div class="notebody"><p>当恢复的资源类型为“单实例”和“集群实例”时展示该参数。</p>
</div></div>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="32.53%" headers="mcps1.3.3.2.4.2.2.2.3.1.1 "><p><span>目标数据库</span></p>
</td>
<td class="cellrowborder" valign="top" width="67.47%" headers="mcps1.3.3.2.4.2.2.2.3.1.2 "><p>当选择恢复至“<span>新位置</span>”时，请选择恢复到的目标数据库。</p>
<div class="note"><span class="notetitle"> 说明： </span><div class="notebody"><p>当恢复的资源类型为“数据库”时展示该参数。</p>
</div></div>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="32.53%" headers="mcps1.3.3.2.4.2.2.2.3.1.1 "><p><span>数据库重命名</span></p>
</td>
<td class="cellrowborder" valign="top" width="67.47%" headers="mcps1.3.3.2.4.2.2.2.3.1.2 "><p>支持对恢复的数据库进行重命名。</p>
<div class="note"><span class="notetitle"> 说明： </span><div class="notebody"><ul><li>当恢复的资源类型为“数据库”时展示该参数。</li><li>创建即时挂载的副本必须是<span class="uicontrol">“<span>正常</span>”</span>状态。</li></ul>
</div></div>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="32.53%" headers="mcps1.3.3.2.4.2.2.2.3.1.1 "><p><span>强制恢复</span></p>
</td>
<td class="cellrowborder" valign="top" width="67.47%" headers="mcps1.3.3.2.4.2.2.2.3.1.2 "><p>默认不开启，开启后可以在数据库页损坏的情况下，将数据强制恢复。</p>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" width="32.53%" headers="mcps1.3.3.2.4.2.2.2.3.1.1 "><p><span>恢复前执行脚本</span></p>
</td>
<td class="cellrowborder" rowspan="3" valign="top" width="67.47%" headers="mcps1.3.3.2.4.2.2.2.3.1.2 "><p>您可以根据实际需求，在恢复任务执行前、执行成功后、执行失败后，执行自定义脚本。</p>
<p><span>请输入脚本名称，脚本名称以</span><strong>.sh</strong><span>结尾。确保脚本已存放在ProtectAgent安装目录下的</span><span class="filepath">“DataBackup/ProtectClient/ProtectClient-E/sbin/thirdparty”</span><span>目录，</span><span style="color:#282B33;">且登录数据库主机的用户（默认为root）对该脚本有可执行权限。</span></p>
<div class="note"><span class="notetitle"> 说明： </span><div class="notebody"><p>当配置了“恢复成功执行脚本”时，即使该脚本执行失败，<span>OceanProtect</span>上也会显示恢复任务的状态为“成功”。请您留意任务详情中是否有后置脚本执行失败的相关提示，如有请及时修正脚本。</p>
</div></div>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" headers="mcps1.3.3.2.4.2.2.2.3.1.1 "><p><span>恢复成功执行脚本</span></p>
</td>
</tr>
<tr><td class="cellrowborder" valign="top" headers="mcps1.3.3.2.4.2.2.2.3.1.1 "><p><span>恢复失败执行脚本</span></p>
</td>
</tr>
</tbody>
</table>
</div>
</p></li><li><span>单击<span class="uicontrol">“<span>确定</span>”</span>。</span><p><div class="note"><img src="public_sys-resources/note_3.0-zh-cn.png"><span class="notetitle"> </span><div class="notebody"><p>恢复完成后需要等待几分钟完成节点间数据同步。</p>
</div></div>
</p></li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>父主题：</strong> <a href="mysql-0046.html">恢复</a></div>
</div>
</div>

<div class="hrcopyright"><hr size="2"></div><div class="hwcopyright">版权所有 &copy; 华为技术有限公司</div></body>
</html>